﻿<Window
    x:Class="Milkify.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Milkify"
    xmlns:mv="clr-namespace:Milkify.Views"
    Title="Milkify"
    WindowStyle="None"
    AllowsTransparency="True"
    Style="{DynamicResource MainWindowStyle}">
    <Grid>
        <Border
            Name="WindowBorder"
            Style="{DynamicResource MainWindowBorderStyle}">
            <DockPanel
                Style="{DynamicResource MainWindowInnerStyle}">
                <Grid
                    Style="{DynamicResource TitleBarStyle}"
                    DockPanel.Dock="Top"
                    MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Column="0" Style="{DynamicResource ApplicationTitleStyle}">Milkify</Label>
                    <Label Grid.Column="1" Style="{DynamicResource AccountNameStyle}">
                        <Hyperlink
                            Command="{Binding NavigateToAccountCommand}"
                            KeyboardNavigation.IsTabStop="False">
                            <Hyperlink.ToolTip>
                                <Border 
                                    Name="TooltipBorder"
                                    Style="{DynamicResource TooltipBorderStyle}">
                                    <StackPanel>
                                        <TextBlock>Go to the account page to:</TextBlock>
                                        <BulletDecorator>
                                            <BulletDecorator.Bullet>
                                                <Ellipse Fill="{Binding RelativeSource={RelativeSource Self}, Path=(TextElement.Foreground)}" Width="5" Height="5" />
                                            </BulletDecorator.Bullet>
                                            <TextBlock>Logout</TextBlock>
                                        </BulletDecorator>
                                        <BulletDecorator>
                                            <BulletDecorator.Bullet>
                                                <Ellipse Fill="{Binding RelativeSource={RelativeSource Self}, Path=(TextElement.Foreground)}" Width="5" Height="5" />
                                            </BulletDecorator.Bullet>
                                            <TextBlock>Access your <Run FontWeight="Bold">Remember The Milk</Run> home page</TextBlock>
                                        </BulletDecorator>
                                    </StackPanel>
                                </Border>
                            </Hyperlink.ToolTip>
                            <TextBlock Name="TextUserName" Style="{DynamicResource AccountHyperlinkStyle}" />
                        </Hyperlink>
                    </Label>
                    <Button 
                        x:Name="AboutButton"
                        Grid.Column="2"
                        Content="?" 
                        Command="{Binding NavigateToAboutPageCommand}" 
                        KeyboardNavigation.IsTabStop="False" 
                        Style="{DynamicResource AboutButtonStyle}">
                        <Button.ToolTip>About Milkify</Button.ToolTip>
                    </Button>
                    <Button 
                        x:Name="MinimizeButton"
                        Grid.Column="3" 
                        Content="_" 
                        Click="MinimizeButton_Click" 
                        KeyboardNavigation.IsTabStop="False" 
                        Style="{DynamicResource MinimizeButtonStyle}">
                        <Button.ToolTip>Minimize Milkify</Button.ToolTip>
                    </Button>
                    <Button 
                        x:Name="CloseButton"
                        Grid.Column="4" 
                        Content="X"
                        Click="CloseButton_Click" 
                        KeyboardNavigation.IsTabStop="False" 
                        Style="{DynamicResource CloseButtonStyle}">
                        <Button.ToolTip>Close Milkify</Button.ToolTip>
                    </Button>
                </Grid>
                <Grid
                    DockPanel.Dock="Bottom"
                    FocusManager.IsFocusScope="True"
                    FocusManager.FocusedElement="{Binding ElementName=TextSearch}"
                    Style="{DynamicResource FunctionsBarStyle}">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Button
                        Grid.Column="0"
                        Command="{Binding AddTaskCommand}">Add _Task</Button>
                    <TextBox
                        Grid.Column="1"
                        Name="TextSearch"
                        GotFocus="TextSearch_GotFocus"
                        GotMouseCapture="TextSearch_GotMouseCapture"
                        KeyUp="TextSearch_KeyUp"></TextBox>
                    <Button
                        Grid.Column="2"
                        Command="{Binding SearchTaskCommand}"
                        CommandTarget="{Binding ElementName=TextSearch}"
                        CommandParameter="{Binding Text, ElementName=TextSearch}">_Search</Button>
                    <Button
                        Grid.Column="3"
                        Command="{Binding ApplicationSettingsCommand}">S_ettings</Button>
                    <ProgressBar
                        Grid.ColumnSpan="4"
                        Grid.Row="1"
                        Name="ProgressRequests"
                        Visibility="Collapsed"
                        Maximum="0"
                        Value="0" 
                        Style="{DynamicResource RequestProgressStyle}"/>
                </Grid>
                <DockPanel>
                    <Grid
                        DockPanel.Dock="Top"
                        Style="{DynamicResource ContentHeaderStyle}">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Button
                            Grid.Column="0"
                            Command="{x:Static NavigationCommands.BrowseBack}"
                            CommandTarget="{Binding ElementName=ViewFrame}"
                            Style="{DynamicResource BackButtonStyle}">Back</Button>
                        <TextBlock
                            Grid.Column="1"
                            Name="TextViewTitle"
                            Text="{Binding ElementName=ViewFrame, Path=Content.Title}"
                            Style="{DynamicResource PageTitleTextStyle}" />
                        <Button
                            Grid.Column="2"
                            Command="{x:Static NavigationCommands.Refresh}"
                            CommandTarget="{Binding ElementName=ViewFrame}"
                            Style="{DynamicResource RefreshButtonStyle}">Refresh</Button>
                        <Button
                            Grid.Column="3"
                            Command="{x:Static NavigationCommands.BrowseHome}"
                            CommandTarget="{Binding ElementName=ViewFrame}"
                            Style="{DynamicResource HomeButtonStyle}">Home</Button>
                    </Grid>
                    <Frame
                        Name="ViewFrame"
                        NavigationUIVisibility="Hidden"
                        KeyboardNavigation.IsTabStop="False"
                        Style="{DynamicResource ContentStyle}">
                    </Frame>
                </DockPanel>
            </DockPanel>
        </Border>
        <!-- Invisible resizing handles -->
        <Rectangle Name="ResizeRight" VerticalAlignment="Stretch" HorizontalAlignment="Right" Width="4" Fill="Transparent" />
        <Rectangle Name="ResizeLeft" VerticalAlignment="Stretch" HorizontalAlignment="Left" Width="4" Fill="Transparent" />
        <Rectangle Name="ResizeBottom" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="4" Fill="Transparent" />
        <Rectangle Name="ResizeTop" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="4" Fill="Transparent" />
        <Rectangle Name="ResizeTopLeft" VerticalAlignment="Top" HorizontalAlignment="Left" Height="8" Width="8" Fill="Transparent" />
        <Rectangle Name="ResizeTopRight" VerticalAlignment="Top" HorizontalAlignment="Right" Height="8" Width="8" Fill="Transparent" />
        <Rectangle Name="ResizeBottomLeft" VerticalAlignment="Bottom" HorizontalAlignment="Left" Height="8" Width="8" Fill="Transparent" />
        <Rectangle Name="ResizeBottomRight" VerticalAlignment="Bottom" HorizontalAlignment="Right" Height="8" Width="8" Fill="Transparent" />
    </Grid>
</Window>
